package pers.zh.parking.data.entity;

import android.os.Parcel;
import android.os.Parcelable;

public class ParkingLot implements Parcelable {

    private int lotId;
    private double latitude;
    private double longitude;
    private String name;
    private String location;
    private int spaceTotal;
    private int spaceFree;
    private int payWay;
    private double price;
    private int distance;
    private ParkingSpace space;

    public ParkingSpace getSpace() {
        return space;
    }

    public void setSpace(ParkingSpace space) {
        this.space = space;
    }

    public int getLotId() {
        return lotId;
    }

    public void setLotId(int lotId) {
        this.lotId = lotId;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public int getSpaceTotal() {
        return spaceTotal;
    }

    public void setSpaceTotal(int spaceTotal) {
        this.spaceTotal = spaceTotal;
    }

    public int getSpaceFree() {
        return spaceFree;
    }

    public void setSpaceFree(int spaceFree) {
        this.spaceFree = spaceFree;
    }

    public int getPayWay() {
        return payWay;
    }

    public String getPayWayStr() {
        switch (payWay) {
            case 1:
            default:
                return "现金支付";
            case 2:
                return "微信支付";
            case 3:
                return "支付宝支付";
        }
    }

    public void setPayWay(int payWay) {
        this.payWay = payWay;
    }

    public double getPrice() {
        return price;
    }

    public String getPriceStr() {
        return String.format("%s元/时", price);
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public ParkingLot() {}

    @Override
    public int describeContents() { return 0; }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.lotId);
        dest.writeDouble(this.latitude);
        dest.writeDouble(this.longitude);
        dest.writeString(this.name);
        dest.writeString(this.location);
        dest.writeInt(this.spaceTotal);
        dest.writeInt(this.spaceFree);
        dest.writeInt(this.payWay);
        dest.writeDouble(this.price);
        dest.writeInt(this.distance);
        dest.writeParcelable(this.space, flags);
    }

    protected ParkingLot(Parcel in) {
        this.lotId = in.readInt();
        this.latitude = in.readDouble();
        this.longitude = in.readDouble();
        this.name = in.readString();
        this.location = in.readString();
        this.spaceTotal = in.readInt();
        this.spaceFree = in.readInt();
        this.payWay = in.readInt();
        this.price = in.readDouble();
        this.distance = in.readInt();
        this.space = in.readParcelable(ParkingSpace.class.getClassLoader());
    }

    public static final Creator<ParkingLot> CREATOR = new Creator<ParkingLot>() {
        @Override
        public ParkingLot createFromParcel(Parcel source) {return new ParkingLot(source);}

        @Override
        public ParkingLot[] newArray(int size) {return new ParkingLot[size];}
    };
}
